%aim: find the frequencies of a text
-module(frequencies).
-export([frequencies/1]).

frequencies(String) ->
frequencies_helper(String,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]).

frequencies_helper([], Frequencies) ->
Frequencies;
frequencies_helper([$A|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A+1,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$B|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B+1,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$C|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C+1,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$D|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D+1,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$E|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E+1,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$F|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F+1,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$G|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G+1,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$H|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H+1,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$I|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I+1,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$J|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J+1,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$K|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K+1,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$L|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L+1,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$M|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M+1,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$N|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N+1,O,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$O|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O+1,P,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$P|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P+1,Q,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$Q|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q+1,R,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$R|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R+1,S,T,U,V,W,X,Y,Z]);
frequencies_helper([$S|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S+1,T,U,V,W,X,Y,Z]);
frequencies_helper([$T|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T+1,U,V,W,X,Y,Z]);
frequencies_helper([$U|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U+1,V,W,X,Y,Z]);
frequencies_helper([$V|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V+1,W,X,Y,Z]);
frequencies_helper([$W|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W+1,X,Y,Z]);
frequencies_helper([$X|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X+1,Y,Z]);
frequencies_helper([$Y|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y+1,Z]);
frequencies_helper([$Z|Tail], [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]) ->
frequencies_helper(Tail, [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z+1]).

